Skip to content

Conversation

toji
Copy link
Contributor

@toji toji commented Sep 23, 2025

Writes the primitive_index to a secondary render target and uses that to highlight the primitive that the pointer is over on subsequent frames. Also includes a mode that visualizes the primitive index. Used as a (somewhat contrived) example of using the primitive_index builtin.

This was based on the deferred shading sample, but has been modified significantly.

Writes the primitive_index to a secondary render target and uses that
to highlight the primitive that the pointer is over on subsequent
frames.
Copy link
Collaborator

@greggman greggman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!

I think it might be nice to add a few more comments in the code. I also notice lots of inconsistent formatting like a: b vs a : b and a + b vs a+b. I don't mind but just thought I'd point it out. npm run lint though does complain about some things though.

@toji
Copy link
Contributor Author

toji commented Sep 23, 2025

Updated with more comments all around, as well as addressing your feedback. I think the formatting issues you pointed out were in the WGSL files, which is why they weren't showing up for my with lint.

Copy link
Collaborator

@beaufortfrancois beaufortfrancois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great sample. Thanks @toji!

Copy link
Collaborator

@beaufortfrancois beaufortfrancois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@toji toji enabled auto-merge (squash) September 25, 2025 16:40
@toji toji merged commit 3dc7f9a into webgpu:main Sep 25, 2025
1 check passed
@toji toji deleted the primitive-picking branch September 25, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants